<template>
	<view class="content">
		<view class="status_bar">
		  <!-- 这里是状态栏 -->
		</view>
		<view class="usertou">
			<view class="quan"><image  :src="baseURL+data.avatar" mode=""></image></view>
			<view class="user_namebox">
				<view class="user_name">{{data.NAME}} </view>
				<view class="uodatas" @click="gopage('/pages/newpages/info')">修改</view>
				<view class="kaipiaoxx" style="color:#F0B199;" @click="gopage('/pages/newpages/kaipiaoxx?look=look')">开票信息 &gt;</view>
			</view>
			<view class="vipLevel">
				<image src="../static/btn_menu.png" mode=""></image>会员等级：{{vipDengj}}级
			</view>
		</view>
		<view class="csss">
			<view class="text_title">我的订单 <!-- <text @click="golist('qb')">全部订单</text> --></view>
			<view class="stu">
				<view @click="golist(0)">
					<img src="/static/icon_wait.png" alt="">
					<view class="">全部</view>
				</view>
				<view @click="golist(1)">
					<img src="/static/icon_wait.png" alt="">
					<view class="">待发货</view>
					<uni-badge v-if="DFH_Num" :text="DFH_Num" :type="'primary'" class="badge"></uni-badge>
				</view>
				<view @click="golist(2)">
					<img src="/static/icon_wait.png" alt="">
					<view class="">待收货</view>
					<uni-badge v-if="DSH_Num" :text="DSH_Num" :type="'primary'" class="badge"></uni-badge>
				</view>
				<view @click="golist(3)">
					<img src="/static/icon_wait.png" alt="">
					<view class="">待评价</view>
					<uni-badge v-if="DPJ_Num" :text="DPJ_Num" :type="'primary'" class="badge"></uni-badge>
				</view>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " @click="scanCode()">
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">扫一扫</text>
				</view>
			</view>
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " @click="gopage('/pages/newpages/workProgressList')">
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">工作台</text>
				</view>
			</view>
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " @click="gopage('/pages/measure/Akeymeasure')">
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">一键评测</text>
				</view>
			</view>
			<!-- <view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " >
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">收藏文章</text>
				</view>
			</view> -->
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " @click="gopage('/pages/IntegralMall/integraList')">
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">积分商城</text>
				</view>
			</view>
			<view class="uni-list-cell">
				<view class="uni-list-cell-navigate uni-navigate-right " @click="downline">
					<image class="lsitIcon" src="../static/icon_yes.png" mode=""></image><text class="lsitIconRight">注销登录</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import API from '../common/api.js';
	import uniBadge from "@/components/uni-badge/uni-badge.vue"
	export default {
		components: {
			uniBadge
		},
		data() {
			return {
				data:[],
				userid:uni.getStorageSync("userid"),
				deptid:uni.getStorageSync("deptid"),
				baseURL:API.baseURL,
				vipDengj:uni.getStorageSync("vip_status"),
				
				DFH_Num:0,
				DSH_Num:0,
				DPJ_Num:0,
			}
		},
		onShow() {
			this.findCompanyInfo();
			
				this.mallOrder_list('{u_id:'+this.userid+',is_pay:1,is_send:0}','DFH_Num');//待发货
				this.mallOrder_list('{u_id:'+this.userid+',is_pay:1,is_send:1,is_confirm:0}','DSH_Num');//待收货
				this.mallOrder_list('{u_id:'+this.userid+',is_pay:1,is_send:1,is_confirm:1,is_comment:0}','DPJ_Num');//待评价
			
		},
		methods: {
			scanCode(url){
				uni.scanCode({
				    success: function (res) {
				        // console.log('条码类型：' + res.scanType);
				        // console.log('条码内容：' + res.result);
						res.result = JSON.parse(res.result)
						uni.navigateTo({
							url:'/pages/huihuandeweizhi/fengxianxuncha.1?id='+res.result.id
						})
				    }
				});
			},
			//获取订单分类总数
			mallOrder_list(datas,type){
				var _this = this;
				uni.request({
					url:this.$API.mallOrder_list,
					method:"POST",
					data:{page:1,rows:1,where:datas},
					header:this.$API.get_head(),
					success: (res) => {
						switch (type){
							case 'DFH_Num':
								_this.DFH_Num = res.data.records
								break;
							case 'DSH_Num':
								_this.DSH_Num = res.data.records
								break;
							case 'DPJ_Num':
								_this.DPJ_Num = res.data.records
								break;
							default:
								break;
						}
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					}
				})
			},
			//注销登录
			downline(){
				uni.removeStorageSync('userid');
				uni.removeStorageSync('deptid');
				uni.removeStorageSync('phone');
				uni.reLaunch({
					url:'login/login'
				})
			},
			golist(e){
				// this.$jump('/pages/shopPages/order/order')
				uni.navigateTo({
					url:'/pages/shopPages/order/order?act='+e
				})
			},
			updatatouxiang(){//修改头像
				var _this = this;
				uni.chooseImage({
					sourceType: ["camera", "album"],
					sizeType: "compressed",
					count: 1,
					success: (res) => {
						_this.tempFilePaths = res.tempFilePaths;
						// console.log(res.tempFilePaths[0])
						uni.uploadFile({
							url: API.upload,
							name: 'file',
							filePath: res.tempFilePaths[0],
							success: function(res) {
								var logo = JSON.parse(res.data);
								_this.uploadLogo(logo)
							},
							fail: function(res) {
								uni.showToast({
									title:"上传失败",
									icon:'none'
								})
								// console.log('上传失败', res);
							}
						});
					}
				});
			},
			uploadLogo(e){
				var _this = this;
				uni.request({
					url:API.uploadLogo,
					data:{
						deptid:_this.deptid,
						logo:e.fileName
					},
					method:"GET",
					header:API.get_head(),
					success: (res) => {
						if(res.data.success){
							_this.findCompanyInfo();
						}
						uni.showToast({
							title:res.data.message,
							icon:"none"
						})
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					}
				})
			},
			gopage(url){
				uni.navigateTo({
					url:url
				})
			},
			findCompanyInfo(){
				var _this=this;
				uni.request({
					url:API.getUserDetail,
					method:"POST",
					data:{
						userid:_this.userid,
					},
					header:API.get_head(),
					success: (res) => {
						_this.data=res.data.data;
					},
					fail: () => {
						uni.showToast({
							title:"加载失败",
							icon:'none'
						})
					 }
				})
			}
		}
	}
	
</script>

<style>
	.touxiang{width: 120upx;height:120upx;vertical-align:middle;margin-right:33upx;border-radius:50%;}
	.left_text{font-size:32upx;color:#333333;}
	.uni-list{margin-bottom:20upx;}
	.uni-list:before{display: none;}
	.uni-list-cell:before{display: none;}
	.uni-list-cell:after{display: none;}
	.uni-list-cell{border-bottom:1px solid #e9e9e9;}
	.paddingcc{padding:44upx 25upx;}
	.paddingcc>text{color: #666666;font-size:32upx;}
	.shop>text{margin-right:50upx;}
	.zhiizhuao{padding:13upx 24upx 13px 13px;}
	.zhiizhuao image{width:156upx; height:114upx;}
	
	
	.content{position: relative;}
	.usertou{background:#E26A3C;display: flex;padding:60rpx 20rpx;position:relative;}
	.quan{width:172upx;height:172upx;background:#419efb;border-radius:50%;margin-right:30upx;}
	.quan image{width:160upx;height:160upx;border-radius:50%;margin:6upx;}
	.user_namebox{font-size:34upx;color:#FFFFFF;margin: auto 0;}
	.user_name{overflow: hidden;text-overflow:ellipsis;white-space: nowrap;max-width:200upx;display:inline-block;vertical-align: middle;}
	.uodatas{display: inline-block;margin-left:20upx; color: #007AFF;}
	.vipLevel{font-size:26upx;color:#666666;background:#FFBE00;position:absolute;right:20upx;bottom:85upx;padding:5upx 20upx;border-radius:20upx;}
	.vipLevel image{width:25upx;height:25upx;margin-right:5upx;vertical-align:middle;}
	/* .csss{padding:0 24upx;position:relative;top:-38upx;} */
	.text_title{padding:29upx 21upx;color:#676165;font-size:24upx;border-bottom:1upx solid #eff2f5;background:#FFFFFF;}
	.text_title text{float:right;}
	
	.stu{overflow:hidden;background:#FFFFFF;padding:26upx 0;margin-bottom:20upx;}
	.stu>view{width:175.5upx;text-align: center;float:left;position:relative;}
	.stu>view>image{width:50upx;height:40upx;display:inline-block;}
	.stu>view>view{font-size:24upx;color:#333333;}
	.badge{
		position: absolute;
		top: -23rpx;
		right: 34rpx;
	}
	
	.kf{background:#FFFFFF;font-size: 34upx;color:#333333;line-height:1;padding:25upx 30upx;}
	.kf>image{width:50upx;height:50upx; vertical-align:middle;padding-right:43upx;}
	
	/*new*/
	.uni-list .lsitIcon{width:50upx;height:50upx;vertical-align: middle;}
	.uni-list .lsitIconRight{position:absolute;left:90upx;}
	/* #ifdef APP-PLUS */
	.status_bar {height: var(--status-bar-height);width: 100%;background: #E26A3C;}
	/* #endif */
</style>
